package com.bobi.ecofavor.model.domain;

import com.baomidou.mybatisplus.annotation.*;

import java.math.BigDecimal;

import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.baomidou.mybatisplus.annotation.TableId;

import java.time.LocalDateTime;
import java.io.Serializable;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;

/**
 * <p>
 * 订单
 * </p>
 *
 * @author wenyuan
 * @since 2023-10-21
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("bobi_order")
@ApiModel(value = "Order对象", description = "订单")
public class Order extends Model<Order> {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    @ApiModelProperty(value = "订单编号")
    private String orderSn;

    @ApiModelProperty(value = "父订单")
    private Integer parentOrder;

    @ApiModelProperty(value = "用户")
    private Integer userId;

    @ApiModelProperty(value = "用户名字")
    private String userName;

    @ApiModelProperty(value = "用户联系方式")
    private String userPhone;

    @ApiModelProperty(value = "是否预定")
    private Boolean isReserved;

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "预定时间")
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    private LocalDateTime scheduledTime;

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @ApiModelProperty(value = "订购时间")
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    private LocalDateTime orderTime;

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @ApiModelProperty(value = "完成时间")
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    private LocalDateTime finishTime;


    @ApiModelProperty(value = "店铺id")
    private Integer storeId;

    @ApiModelProperty(value = "店铺名称")
    private String storeName;

    @ApiModelProperty(value = "店铺电话（冗余字段）")
    private String storePhone;

    @ApiModelProperty(value = "店铺种类（冗余字段）")
    private Integer storeCategory;

    @ApiModelProperty(value = "商品编号")
    private Integer goodsId;

    @ApiModelProperty(value = "商品类型")
    private Integer goodsCategory;

    @ApiModelProperty(value = "商品名称")
    private String goodsName;

    @ApiModelProperty(value = "商品数量")
    private BigDecimal goodsNum;

    @ApiModelProperty(value = "商品图片")
    private String goodsImage;

    @ApiModelProperty(value = "参数列表")
    private String goodsParam;

    @ApiModelProperty(value = "订单状态（已取消、待支付、已支付、未完成、已完成）")
    private Integer orderStatus;

    @ApiModelProperty(value = "选择使用的优惠券")
    private String selectedCoupons;

    @ApiModelProperty(value = "备注")
    private String remark;

    @ApiModelProperty(value = "总计金额")
    private BigDecimal totalMoney;

    @ApiModelProperty(value = "优惠扣减")
    private BigDecimal discountMoney;

    @ApiModelProperty(value = "结算金额")
    private BigDecimal settlementMoney;

    @ApiModelProperty(value = "支付方式")
    private Integer paymentMod;

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @ApiModelProperty(value = "创建时间")
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    private LocalDateTime createTime;

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @ApiModelProperty(value = "更改时间")
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    private LocalDateTime updateTime;


    @TableLogic
    @ApiModelProperty(value = "逻辑删除")
    private Boolean isDeleted;


    @Override
    public Serializable pkVal() {
        return this.id;
    }

}
